package code.tools.behavior.achieve 
{
	import code.tools.behavior.IDisappear;
	
	import com.greensock.TweenLite;
	import com.greensock.easing.Back;
	
	import flash.display.Sprite;
	
	/**
	 * 缩放模式消失
	 * @author CYang
	 */
	public class DisappearScale implements IDisappear 
	{
		/**
		 * 面板引用
		 */
		private var _mPanel:Sprite;
		/**
		 * 面板出现后执行的操作
		 */
		private var _callBack:Function;
		/**
		 * 构造函数
		 * @param	_mPanel 面板
		 * @param	callback 执行函数
		 */
		public function DisappearScale(_mPanel:Sprite, callback:Function = null) 
		{
			this._mPanel = _mPanel;
			this._callBack = callback;
		}
		/**
		 * 消失
		 */
		public function disappear():void
		{
			_mPanel.mouseEnabled = _mPanel.mouseChildren = false;
			TweenLite.to(_mPanel, 0.5, { scaleX:0, scaleY:0, ease:Back.easeIn, onComplete:disComplete } );
		}
		
		private function disComplete():void{
			_mPanel.mouseEnabled = _mPanel.mouseChildren = true;
			if(_callBack != null) _callBack();
		}
		
	}

}